package main.java;

import java.util.Objects;

public class Student {
    private String id;    // 学号
    private String name;  // 姓名
    private int age;      // 年龄
    private double score; // 成绩

    // 构造器
    public Student(String id, String name, int age, double score) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.score = score;
    }

    // Getter方法（用于排序、转换）
    public String getId() { return id; }
    public String getName() { return name; }
    public int getAge() { return age; }
    public double getScore() { return score; }

    // 重写toString()：用于文件写入（格式：id,name,age,score）
    @Override
    public String toString() {
        return id + "," + name + "," + age + "," + score;
    }

    // 重写equals()和hashCode()：基于学号去重（供DuplicateRemover使用）
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(id, student.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}